﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    
                    xmlns:breadcrumpbc="clr-namespace:BreadcrumbLib.BaseControls.Breadcrumb"
                    xmlns:bc="clr-namespace:BreadcrumbLib.BaseControls"
                    xmlns:uc="clr-namespace:BreadcrumbLib.Controls.Breadcrumbs"
                    xmlns:suggest="clr-namespace:BreadcrumbLib.Controls.SuggestBox"
                    xmlns:conv="clr-namespace:BreadcrumbLib.Converters"
                    >
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/BreadcrumbLib;component/Themes/Default/Buttons.xaml" />
    <ResourceDictionary Source="/BreadcrumbLib;component/Themes/Default/Brushes.xaml" />
	</ResourceDictionary.MergedDictionaries>

  <ControlTemplate x:Key="BreadcrumbTemplate" TargetType="{x:Type uc:BreadcrumbBase}">
    <Border x:Name="bdr">
      <Border BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderThickness="1">
        <Grid x:Name="BreadcrumbBackgroundGrid" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" >
          <Grid.Resources>
            <conv:BoolToVisibilityCollapsedConverter x:Key="btv" />
            <conv:FlipBoolConverter x:Key="fb" />
            <conv:FlipBoolToVisibilityConverter x:Key="fbtvc" />
            <conv:BoolToVisibilityCollapsedConverter x:Key="btvc" />
          </Grid.Resources>

          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
          </Grid.ColumnDefinitions>

          <ProgressBar Background="Transparent" Foreground="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}"
                             IsIndeterminate="{Binding IsIndeterminate, RelativeSource={RelativeSource TemplatedParent}}" Opacity="0.5" Grid.ColumnSpan="3"
                             Visibility="{Binding IsProgressbarVisible, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource btv}}"
                             Value="{Binding Progress, RelativeSource={RelativeSource TemplatedParent}}" />

          <ToggleButton x:Name="PART_Toggle"  Grid.Column="0"  Padding="2,0" VerticalAlignment="Stretch"
                        IsChecked="{Binding IsBreadcrumbVisible, RelativeSource={RelativeSource TemplatedParent}}" 
                        Width="{TemplateBinding ActualHeight}"
                        Template="{StaticResource BaseButton}" Background="Transparent" >

            <ContentControl ContentTemplate="{TemplateBinding IconTemplate}"  
                            Content="{Binding SelectedValue, RelativeSource={RelativeSource TemplatedParent}}" />
          </ToggleButton>

          <suggest:SuggestBoxBase x:Name="PART_TextBox" Grid.Column="1" BorderBrush="Transparent"
                                   DisplayMemberPath="{Binding DisplayMemberPath, RelativeSource={RelativeSource TemplatedParent}}"
                                   ValuePath ="{Binding ValuePath, RelativeSource={RelativeSource TemplatedParent}}"
                                   Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}"
                                   Suggestions="{Binding Suggestions, RelativeSource={RelativeSource TemplatedParent}}"
                                   IsEnabled="{Binding IsBreadcrumbVisible, Converter={StaticResource fb}, RelativeSource={RelativeSource TemplatedParent}}" 
                                   Visibility="{Binding IsBreadcrumbVisible, Converter={StaticResource fbtvc}, RelativeSource={RelativeSource TemplatedParent}}" >
            <!--<bc:SuggestBoxBase.Text>
                            <Binding Path="SelectedPathValue" RelativeSource="{RelativeSource TemplatedParent}" UpdateSourceTrigger="Explicit">                                
                            </Binding>
                        </bc:SuggestBoxBase.Text>-->
          </suggest:SuggestBoxBase>

          <breadcrumpbc:BreadcrumbCore x:Name="PART_BreadcrumbCore" Grid.Column="1"
                                       ItemsSource="{Binding ItemsSource, RelativeSource={RelativeSource TemplatedParent}}"
                                       RootItemsSource="{Binding RootItemsSource, RelativeSource={RelativeSource TemplatedParent}}"
                                       DropDownHeight="{TemplateBinding DropDownHeight}"
                                       DropDownWidth="{TemplateBinding DropDownWidth}"
                                       HeaderTemplate="{TemplateBinding HeaderTemplate}"
                                       IconTemplate="{TemplateBinding IconTemplate}"
                                       Visibility="{Binding IsBreadcrumbVisible, Converter={StaticResource btvc}, RelativeSource={RelativeSource TemplatedParent}}">
          </breadcrumpbc:BreadcrumbCore>

          <ContentControl Content="{TemplateBinding Buttons}" Grid.Column="2" VerticalAlignment="Stretch" Margin="2,0" />

        </Grid>
      </Border>
    </Border>
  </ControlTemplate>

  <Style TargetType="{x:Type uc:BreadcrumbBase}">
    <Style.Resources>
      <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}" >
        <Setter Property="Margin" Value="1" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template" Value="{StaticResource BaseButton}" />
      </Style>
    </Style.Resources>
    <Setter Property="Template" Value="{StaticResource BreadcrumbTemplate}" />
    <!--<Setter Property="Height" Value="30" />-->
    <Setter Property="ItemsPanel">
      <Setter.Value>
        <ItemsPanelTemplate>
          <StackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>